package com.trover.myapplication.core.http

import okhttp3.Interceptor
import okhttp3.Response

class TokenInterceptor:Interceptor{
    override fun intercept(chain: Interceptor.Chain): Response {
        var originalRequest = chain.request()//获取原始请求
        val requestBuilder = originalRequest.newBuilder() //建立新的请求
            .addHeader("Accept", "application/json")
            .addHeader("Content-Type", "application/json; charset=utf-8")
            .method(originalRequest.method, originalRequest.body)
//        var tokenRequest:Request? = null; //带有token的请求
//        if (StringUtils.isEmpty(App.mmkv.decodeString(BaseConfig.TOKEN,null))){
//            return chain.proceed(requestBuilder.build());
//        }
        originalRequest = requestBuilder.build()
//        tokenRequest = requestBuilder
//            .header("Authorization","Bearer "+App.mmkv.decodeString(BaseConfig.TOKEN,null))
//            .build();
        return chain.proceed(originalRequest);
    }
}